import { ChannelType } from '@/store/reducer/channel';
import request from '@/utils/request';

/** 获取所有的频道列表 */
export const getAllChannelsAPI = () => {
  return request({
    url: '/v1_0/channels',
  });
};

/** 获取用户的频道列表 */
export const getUserChannelsAPI = () => {
  return request({
    url: '/v1_0/user/channels',
  });
};

export type ChannelParamsType = { channels: ChannelType[] };
/** 设置用户关注的频道 */
export const setUserChannelsAPI = (data: ChannelParamsType) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data,
  });
};

/** 删除用户关注的频道 */
export const delUserChannelsAPI = (id: number) => {
  return request({
    url: `/v1_0/user/channels/${id}`,
    method: 'delete',
  });
};
